﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using WinFormsUI.Docking;
using SmartControls.Controls;
using SmartCMS.UI.Helper;

namespace SmartCMS.UI.SystemManage
{
    public partial class SystemMenus : DockContent
    {
        public SystemMenus()
        {
            InitializeComponent();
        }

        private void SystemMenus_Load(object sender, EventArgs e)
        {
            List<MenuItemEntity> lstMenu = new List<MenuItemEntity>();
            var MenusP = DBHelper.GetCollection<SmartCMS.UI.ViewModels.MenuItemEntity>().Find(x => x.PID == 0).ToList();
            foreach (var item in MenusP)
            {
                MenuItemEntity pModel = new MenuItemEntity()
                {
                    Key = item.WindowName,
                    Text = item.MenuName,
                };
                pModel.Childrens = new List<MenuItemEntity>();
                var MenusC= DBHelper.GetCollection<SmartCMS.UI.ViewModels.MenuItemEntity>().Find(x => x.PID == item.ID).ToList();
                foreach (var item2 in MenusC)
                {
                    MenuItemEntity cModel = new MenuItemEntity()
                    {
                        Key = item2.WindowName,
                        Text = item2.MenuName,
                    };
                    pModel.Childrens.Add(cModel);
                }
                lstMenu.Add(pModel);
            }
            this.SystemMenusList.DataSource = lstMenu;
        }

        private void SystemMenusList_SelectedItem(object sender, EventArgs e)
        {
            
        }
    }
}
